package com.ace.token.config.locale;

import com.ace.token.common.bean.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

import java.util.Locale;

@Component
public class RLocale {

    @Autowired
    public MessageSource messageSource;

    public ResponseDTO getDTO (String message,int code){
        Locale locale = LocaleContextHolder.getLocale();
        message = messageSource.getMessage(message, null, locale);
        ResponseDTO dto = new ResponseDTO(message,code);
        return  dto;
    }
    public String getMessage (String message){
        Locale locale = LocaleContextHolder.getLocale();
        return messageSource.getMessage(message, null, locale);
    }
}
